
package es.realtimesystems.simplemulticast;
import java.net.*;

public class PruebaCanalUnicastEmisor implements CanalCallback
{

  public PruebaCanalUnicastEmisor()
  {
  final String mn="PRUEBACANALUNICASTEMISOR()";

  try{
  Address dirUcast = new Address (InetAddress.getByName ("192.168.0.7"),2100);


  CanalUnicast canalUcast = CanalUnicast.getInstance(dirUcast,null,null,null);

  canalUcast.setCallback (this,1);

  Log.log (mn,"Tiempo INICIO: " + Temporizador.tiempoActualEnMseg());
  for (int i=1;i<=8000;i++)
   {
    Buffer buf = new Buffer (4);
    buf.addInt(i,0);
    canalUcast.send (buf,dirUcast);
   }
  Log.log (mn,"Tiempo FIN: " + Temporizador.tiempoActualEnMseg());

while (true)
{
 Temporizador.sleep (120000);
}
  }catch (java.net.UnknownHostException e)
   {
    Log.log (mn,""+e);
   }
  catch (java.io.IOException e)
   {
    Log.log (mn,""+e);
   }
  }

  public static void main(String[] args)
  {
   new PruebaCanalUnicastEmisor();
  }
public void canalCallback(int arg, Buffer buf, Address src)
  {
    final String  mn = "canalCallback(int,Buffer,Address)";

    Log.log (mn,"Tiempo de recepcion: " + Temporizador.tiempoActualEnMseg());
    Log.log (mn,"buf: " + buf);
    Log.log (mn,"Numero bytes recibidos: " + buf.getLength());
  }


}
